﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tank.Properties;

namespace Tank
{
    class Explosion : ClassObject
    {
        public bool IsOver { get; set; }
        private int playSpeed = 2;
        private int playCount = -1;
        private int index = 0;
        private Bitmap[] bmpArray = new Bitmap[] {
            Resources.EXP1,
            Resources.EXP2,
            Resources.EXP3,
            Resources.EXP4,
            Resources.EXP5
        };
        public Explosion(int x, int y)
        {
            foreach(Bitmap i in bmpArray)
            {
                //设置图片的透明度
                i.MakeTransparent(Color.Black);
            }
            this.X = x - bmpArray[0].Width / 2;
            this.Y = y - bmpArray[0].Height / 2;
            this.IsOver = false;
        }
        protected override Image GetImage()
        {
            if (index > 4)
            {
             
                return bmpArray[4];
                
            }
            return bmpArray[index];
        }
        public new  void DrawSelf()
        {
 
        }
        public override void Update()
        {
            
            playCount++;
            index = (playCount - 1) / playSpeed;
            if(index > 4)
            {
                IsOver = true;
            }
            base.Update();
        }

    }
}
